﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using Chefbook.DataObjects;
using System.Globalization;
using Chefbook.DataAccessLayer;

namespace Chefbook.UserActions
{
    public class MoveCategoryAction : UserActionBase
    {
        private Category categoryToMove, newParent, oldParent;

        public MoveCategoryAction(Category categoryToMove, Category newParent)
        {
            this.categoryToMove = categoryToMove;
            this.newParent = newParent;
            this.oldParent = categoryToMove.Parent;
        }

        public override void DoAction()
        {
            base.DoAction();
            categoryToMove.Parent = newParent;
        }

        public override void UndoAction()
        {
            base.UndoAction();
            categoryToMove.Parent = oldParent;
        }

        public override string ToString()
        {
            return string.Format(CultureInfo.CurrentUICulture, "Move Category '{0}' from '{1}' to '{2}'", categoryToMove, oldParent, newParent);
        }
    }
}
